#include <iostream>
#include <algorithm>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;

void selectionSort (int *array, int size)
{
    if (size == 1) return;
    int *min = array;
    for (int j = 0; j < size; ++j)
        if (*min > array[j]) min = &array[j];
    swap (*min, array[0]);
    selectionSort (array+1, size-1);
}

int main()
{
    const int SIZE = 10;
    srand ((unsigned)time(NULL));
    int array[SIZE];
    generate_n (array, SIZE, rand);
    
    for (int i = 0; i < SIZE; ++i)
        cout << array[i] << " ";
    cout << endl;

    selectionSort (array, SIZE);

    for (int i = 0; i < SIZE; ++i)
        cout << array[i] << " ";
    cout << endl;

    return 0;
}

